package com.atguigu.gulimall.order.vo;

import com.sun.org.apache.xpath.internal.operations.Bool;
import lombok.Data;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 订单确认页需要用到的数据
 * @author 马迎迎
 * @Title: OrderConfirmVo
 * @Package com.atguigu.gulimall.order.vo
 * @Description: TODO(添加描述)
 * @date 2021年05月29日 14:21
 */


public class OrderConfirmVo {
    // 收货地址， ums_member_receive_address 表
    private List<MemberAddressVo> addresses;
    // 购物清单(所有选中的购物项)， 根据购物车页面传递过来的 skuIds 查询
    private List<OrderItemVO> items;
    // 可用积分， ums_member 表中的 integration 字段
    private Integer integration;

    private Map<Long, Boolean> stocks;
    //订单总额
//    private BigDecimal total;
    //应付总额
//    private BigDecimal payPrice;
    // 订单令牌， 防止重复提交
    private String orderToken;

    public List<MemberAddressVo> getAddresses() {
        return addresses;
    }

    public void setAddresses(List<MemberAddressVo> addresses) {
        this.addresses = addresses;
    }

    public List<OrderItemVO> getItems() {
        return items;
    }

    public void setItems(List<OrderItemVO> items) {
        this.items = items;
    }

    public Integer getIntegration() {
        return integration;
    }

    public void setIntegration(Integer integration) {
        this.integration = integration;
    }

    public BigDecimal getTotal() {
        BigDecimal res=new BigDecimal(0);
        if(items!=null){
            for (OrderItemVO item : items) {
                res = res.add(item.getPrice().multiply(new BigDecimal(item.getCount())));
            }
        }
        return res;
    }

    public Integer getCount(){
        Integer res=0;
        for (OrderItemVO item : items) {
            res+=item.getCount();
        }
        return res;
    }


    public BigDecimal getPayPrice() {
        return getTotal();
    }

    public String getOrderToken() {
        return orderToken;
    }

    public void setOrderToken(String orderToken) {
        this.orderToken = orderToken;
    }

    public Map<Long, Boolean> getStocks() {
        return stocks;
    }

    public void setStocks(Map<Long, Boolean> stocks) {
        this.stocks = stocks;
    }
}
